<?
require("config.php");

$location_status .= "| Add";
$show_backnav = "menu";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){

	$dir = "med_promotion/";

	if ($Picture1) myUpload($Picture1,$Picture1_name,$dir);
	if ($Picture2) myUpload($Picture2,$Picture2_name,$dir);
	if ($Picture3) myUpload($Picture3,$Picture3_name,$dir);

	if ($Picture1_name == null) $Picture1_name = $bk_Picture1;
	if ($Picture2_name == null) $Picture2_name = $bk_Picture2;
	if ($Picture3_name == null) $Picture3_name = $bk_Picture3;


	if ($sm_Picture1) myUpload($sm_Picture1,"sm_" . $Picture1_name,$dir);
	if ($sm_Picture2) myUpload($sm_Picture2,"sm_" . $Picture2_name,$dir);
	if ($sm_Picture3) myUpload($sm_Picture3,"sm_" . $Picture3_name,$dir);


	if ($remove_1=="ture") $Picture1_name=NULL;
	if ($remove_2=="ture") $Picture2_name=NULL;
	if ($remove_3=="ture") $Picture3_name=NULL;


	$Date = "$Year-$Month-$Day";

   $field = array(
	"code", 
	"date", 
	"subject", 
	"details",
	"picture1",
	"picture2",
	"picture3",
    "status",
	"publish_date",
	);

   $content = array(
	$Code,
	$Date,
	$Subject,
	$Details,
	$Picture1_name,
	$Picture2_name,
	$Picture3_name,
	$Status,
	"$myYear-$myMonth-$myDay",
	);

   myInsert($table,$field,$content);


   header("location:" . $rela_path . "share/msg.php?v=3401");

   exit();

}else{

  if (checkCode($table,$Code)){

	header("location:" . $rela_path . "share/msg.php?v=9001");

	exit();
  
  }

}

require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");


?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="add">
<input name="Code" type="hidden" value="<?print($Code)?>">




<table width="95%" border="0" align="center">
  <tr> 
    <td valign="top"> <table border="0" cellspacing="5" cellpadding="1">
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code : </td>
            <td><?print($Code)?></td>
          </tr>
          <tr> 
            <td class="tdheader">Date :</td>
            <td><?print(FFPdate(date("Y-m-d")))?>
			  </td>
          </tr>
          <tr> 
            <td class="tdheader">Subject :</td>
            <td><input type="text" class="text" name="Subject" size="56"></td>
          </tr>
          <tr> 
            <td class="tdheader">Details : </td>
            <td><textarea class="text" name="Details" cols="55" rows="20"></textarea></td>
          </tr>




          <tr> 
            <td class="tdheader">Picture 1</td>
            <td>
			
			<?removeImage($Picture1,"remove_1")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture1,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture1" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture1,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture1" size="40">
			<br><br>


            </td>
          </tr>



          <tr> 
            <td class="tdheader">Picture 2</td>
            <td>
			
			<?removeImage($Picture2,"remove_2")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture2,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture2" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture2,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture2" size="40">
			<br><br>


            </td>
          </tr>


          <tr> 
            <td class="tdheader">Picture 3</td>
            <td>
			
			<?removeImage($Picture3,"remove_3")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture3,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture3" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture3,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture3" size="40">
			<br><br>


            </td>
          </tr>







          <tr> 
            <td class="tdheader">Publish :</td>
            <td> 
              <?

$sourceData = array(
  "Yes",
  "No",
  );

$boxName="Status";

$value=$Status;

FFPCheckBox("Status",$Status,$sourceData,$sourceLabel);

?>
          </tr>
          <tr> 
            <td class="tdheader">Publishing Date : </td>
            <td><?print(FFPtime(date("Y-m-d H:i")))?></td>
          </tr>


             
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('news_menu.php',1);return false;"> <input type="image" src="../../images/bt_save.gif">
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
    </td>

  </tr>
</table>
<br>
<br>
<br>


</form>

<?
require($rela_path . "inc/footer.php");
?>
